<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:78:"/Users/yandian/work/matian/application/admin/view/bootstrap/codeTool/html.html";i:1490672788;}*/ ?>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2><?php echo $title; ?></h2>
        <ol class="breadcrumb">
            <li>
                <a href="#">首页</a>
            </li>

            <li class="active">
                <strong><?php echo $title; ?></strong>
            </li>
        </ol>
    </div>

</div>

<div class="wrapper wrapper-content animated fadeInRight ecommerce">

    <div class="ibox-content m-b-sm border-bottom" id="form1">
        <div class="row">
            <?php if(is_array($fields)): $i = 0; $__LIST__ = $fields;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;if($vo['field'] != 'id' && $vo['field'] != 'create_time'): ?>
            <div class="col-sm-3">
                <div class="form-group">
                    <label class="control-label" for="<?php echo $vo['field']; ?>"><?php echo $vo['title']; ?></label>
                    <?php if($vo['type'] == 'select'): ?>
                    <select id="<?php echo $vo['field']; ?>" name="<?php echo $vo['field']; ?>"
                            class="form-control">
                        <option value="">---请选择---</option>
                        <?php if(is_array($vo['options'])): $i = 0; $__LIST__ = $vo['options'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$s): $mod = ($i % 2 );++$i;?>
                        <option value="<?php echo $key; ?>"><?php echo $s; ?></option>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </select>
                    <?php else: ?>
                    <input type="text" id="<?php echo $vo['field']; ?>" name="<?php echo $vo['field']; ?>" placeholder="<?php echo $vo['title']; ?>"
                           class="form-control">
                    <?php endif; ?>
                </div>
            </div>
            <?php endif; endforeach; endif; else: echo "" ;endif; ?>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <a class="btn btn-success btn-outline" href="#{:U('form')}">
                    <i class="fa fa-edit"></i>
                    <span class="bold">添加</span>
                </a>
            </div>
            <div class="col-sm-6 text-right">
                <button class="btn btn-default" data-op="reset">
                    <i class="fa fa-refresh"></i>
                    <span class="bold">重置</span>
                </button>
                &nbsp;
                &nbsp;
                <button class="btn btn-primary" data-op="search">
                    <i class="fa fa-search"></i>
                    <span class="bold">查询</span>
                </button>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-content">
                    <table class="footable table table-stripped toggle-arrow-tiny" id="footable">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php 
$columns = '';
foreach($fields as $k=>$v){
$column= '{';
if(empty($v['title']) || empty($v['field']) || $v['field'] == 'id'){
continue;
}
foreach(['field','title','formatter','options'] as $field){
if(!empty($v[$field])){
if($column!='{'){
$column .= ',';
}
if($field == 'field' || $field == 'title' || $field == 'title'){
$column .= ($field=='field'?'name':$field).':\''.$v[$field]."'";
}else{
if($field=='formatter' && $v[$field] == 'image'){
$column .= $field.':\''.$v[$field].'\'';
}else{
$column .= $field.':'.$v[$field];
}
}
}
}
if($k <= 1){
$column .= ",sortable: true";
}elseif($k >= 5){
$column .= ",sortable: true,breakpoints:'xs sm md'";
}else{
$column .= ",sortable: true,breakpoints:'xs sm md'";
}
$column .= '}';
if(!empty($columns)){
$columns .= "\n\t\t\t\t,";
}
$columns .= $column;
}
$columns.="\n";
 ?>
<script>
    $(document).ready(function () {
        YFootTable.create('#footable', {
            baseUrl: "{:U('<?php echo $name; ?>/')}",
            searchForm: '#form1',
            columns: [
                <?php echo $columns; ?>
            ],
            actions: ['view', 'edit', 'remove']
        });
    });
</script>